import 'package:reactive_forms/reactive_forms.dart';
import 'package:yt_devops/model/user_model.dart';

/// Represents a control value accessor that convert between data types
/// [Poi] and [String].
class UsermodelValueAccessor extends ControlValueAccessor<UserModel, String> {
  UsermodelValueAccessor();

  @override
  String modelToViewValue(UserModel? modelValue) {
    return modelValue == null ? '' : (modelValue.userName ?? '');
  }

  @override
  UserModel? viewToModelValue(String? viewValue) {
    return viewValue == null || viewValue.trim().isEmpty
        ? null
        : UserModel(userName: viewValue);
  }
}
